import { VuexModule, Module, Action, getModule, Mutation } from 'vuex-module-decorators'
import { commonAction } from '@/utils/common'
import store from '@/store'
@Module({ dynamic: true, name: 'report', store, namespaced: false })
class Report extends VuexModule {
  public stateList: any = [] // 座席状态列表
  public satisfactionList: any = [] // 默认满意度列表
  public callTypes = [
    { label: '呼入', value: '1' },
    { label: '自动外呼', value: '4' }
  ]

  @Mutation
  private SET_STATELIST (list) {
    this.stateList = list
  }

  @Mutation
  private SET_SATISFACTIONLIST (list) {
    this.satisfactionList = list
  }

  @Action
  public getStateList () {
    return commonAction({ url: '/im-center/action/user/status/cache', method: 'POST' }).then(res => {
      if (res.success) {
        this.SET_STATELIST(res.data)
        return res.data
      }
    })
  }

  @Action
  public getSatisfactionList () {
    return commonAction({ url: '/im-center/action/config/satisfaction/list', method: 'post', data: {} }).then(res => {
      if (res.success) {
        this.SET_SATISFACTIONLIST(res.data.list[0].radioTagText)
        return res.data.list[0].radioTagText
      }
    })
  }
}

export const ReportModule = getModule(Report)
